﻿
namespace visinia.SmartEngine
{
    public class ImageController
    {
        /// <summary>
        /// Resolves the image url for the image display on the webpage
        /// </summary>
        /// <param name="data">The data which has the image urls to resolve</param>
        /// <returns>The string with the image url resolved for display</returns>
        public static string ResolveImagesForDisplay(string data)
        {
            if (string.IsNullOrEmpty(data))
                return null;
            string root = WebRoots.GetWebRoot;
            string replace = "src=\"image.axd?picture=";
            string replaceWith = "src=\"" + root + "image.axd?picture=";
            return data.Replace(replace, replaceWith);            
        }

        ///// <summary>
        ///// Resolves the image url for data storage
        ///// </summary>
        ///// <param name="data">The data string which contains the images urls in it</param>
        ///// <returns>The string with image url resolved for data storage</returns>
        //public static string ResolveImagesForStorage(string data)
        //{
        //    string root = WebRoots.GetWebRoot;            
        //    string replace = "src=\"" + root + "image.axd?picture=";
        //    string replaceWith = "src=\"image.axd?picture=";
        //    return data.Replace(replace, replaceWith);
        //}
    }
}
